<template>
  <div>
    <el-table :data="tableData"
              border
              style="width: 100%">
      <el-table-column prop="user.account"
                       label="用户"
                       width="180">
      </el-table-column>
      <el-table-column prop="user.department"
                       label="部门"
                       width="130">
      </el-table-column>
      <el-table-column prop="role"
                       label="角色"
                       width="150">
      </el-table-column>
      <el-table-column prop="countTraining"
                       label="参加的培训"
                       width="100">
      </el-table-column>
      <el-table-column prop="countCourse"
                       label="参加的课程"
                       width="100">
      </el-table-column>
      <el-table-column prop="nowTraining"
                       label="进行中的培训"
                       width="100">
      </el-table-column>
      <el-table-column prop="nowCourse"
                       label="进行中的课程"
                       width="100">
      </el-table-column>
      <el-table-column prop="studyTime"
                       label="学习总时长"
                       width="100">
      </el-table-column>
      <el-table-column label="操作">
        <template slot-scope="scope">
          <el-button size="mini"
                     type="success"
                     @click="updatePrem(scope.$index, scope.row)">查看用户详情</el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
export default {
  data () {
    return {
      tableData: [],
      editFormVisible: false, //控制编辑页面显示与隐藏
      title: '添加',
      editForm: {
        perm: "",
        description: "",
        flag: "",
        id: ""
      },
    }
  },
  created () {
    this.getdata()
  },
  inject: ["refresh"],
  methods: {
    getdata () {
      this.$axios.get('/api/study/findAll').then(res => {
        if (res.data.code == 200) {
          this.tableData = res.data.data
        }
      })
    },
    updatePrem: function (index, row) {
      localStorage.setItem("studyid", row.user.id),
        this.$router.push({ name: "details", params: { id: '' } })
    },
    closeDialog () {
      this.editFormVisible = false
    }
  }
}
</script>